package ft;

import java.io.File;

public class T1 {

    public static void main(String[] args) {
        String path = "D:\\JAVA";		//要遍历的路径
        File file = new File(path);		//获取其file对象
        func(file);
    }

    private static void func(File file){
        File[] fs = file.listFiles();
        for(File f:fs){
            if(f.isDirectory())	//若是目录，则递归打印该目录下的文件
                func(f);
            if(f.isFile()) {
                if (isYaml(f.getName())) {
                    System.out.println(f.getAbsolutePath());
                }
            }
        }
    }

    private static boolean isYaml(String name) {
        int postIndex = name.lastIndexOf(".");
        String postName = name.substring(postIndex+1);
        return "yaml".equals(postName);
    }
}
